﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Repositories;
using Repositories.Interfaces;
using System.Globalization;

namespace AsiaSnackExpress
{
    public partial class DetailGroupMeal : System.Web.UI.UserControl
    {
        IGroupMealRepository _groupMealRep;
        public IGroupMealRepository GroupMealRep
        {
            get
            {
                if (_groupMealRep == null)
                {
                    _groupMealRep = DIHelper.Resolve<IGroupMealRepository>();
                }
                return _groupMealRep;
            }

        }

        ICategoryRepository _categoryRep;
        public ICategoryRepository CategoryRep
        {
            get
            {
                if (_categoryRep == null)
                {
                    _categoryRep = DIHelper.Resolve<ICategoryRepository>();
                }
                return _categoryRep;
            }

        }

        public List<GroupMeal> GroupMealDataSource
        {
            get
            {
                return (List<GroupMeal>)repGoup.DataSource;
            }
            set
            {
                if (value != null && value.Count > 0)
                {
                    repGoup.DataSource = value;
                    repGoup.DataBind();
                }
                else
                    this.Visible = false;
            }
        }

        int categoryOrder;
        public int CategoryOrder
        {
            get
            {
                return categoryOrder;
            }
            set
            {
                categoryOrder = value;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            Category current = CategoryRep.GetCategoryByOrder(CategoryOrder);
            if (current != null)
            {
                GroupMealDataSource = GroupMealRep.GetAllGroupMealByCategory(current.Id);
                txtTitle.Text = current.NameByLanguage;

              
            }
            else
                this.Visible = false;

        }
    }
}